#include <iostream>
using namespace std;
#include "stdlib.h"
#include "time.h"
int main()
{
    int a, b, numofques=0, numofright=0;
    char inquiry;
    srand(time(NULL));
    cout << "  huanying lai zuo liangwei shu de jiajian fang.  " << endl;
    do
    {
        int temp = rand()%2;
        a = rand()%100;
        b = rand()%100;

        int key;
        if (temp == 0)
        {
            cout << a << '+' << b << endl;
            key = a+b;
        }
        else
        {
            cout << a << '-' << b << endl;
            key = a-b;
        }

        int ans;
        cin >> ans;

        if (ans == key) {
            numofright++;
            cout << "You are right!\n";
        } else {
            numofques++;
            cout << "You are wrong, come on!\n";
        }

        cout << "Play again? (Press n or N to quit!)"	<< endl;
        cin >> inquiry;

    }while ( inquiry != 'n' && inquiry != 'N');

    cout << "ni de zhengque lv shi : " << ((float)numofright/(numofright+numofques))*100 << '%' <<endl;

    return 0;
}
